package nthu.web.model.domain;

import java.util.Comparator;

import org.json.JSONException;
import org.json.JSONObject;

public class MemoStampComparator implements Comparator{

	public int compare(Object arg0, Object arg1){
		JSONObject object1 = (JSONObject) arg0;
		JSONObject object2 = (JSONObject) arg1;
		
		try {
			if(object1.getLong("stamp") > object2.getLong("stamp")){
				return -1;
			}
			if(object1.getLong("stamp") < object2.getLong("stamp")){
				return 1;
			}
			if(object1.getLong("stamp") == object2.getLong("stamp")){
				return 0;
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

}
